// app.js
App({
  onLaunch() {


    const isLoggedIn = wx.getStorageSync('userId');
        if (!isLoggedIn) {
            wx.showModal({
                title: '未登录',
                content: '登录后才能访问系统',
                confirmText: '登录',
                showCancel: false, // 关键：隐藏取消按钮
                success: (res) => {
                    if (res.confirm) {
                      wx.navigateTo({
                        url: '/pages/userInfo/userInfo'
                    });
                      wx.login({
                        success: (res) => {
                         wx.request({
                           url: 'http://a1.iwmls.com/index/login/login2',
                           method: 'POST',
                           data: {
                             code: res.code
                           }, success: (response) => {
                              wx.setStorageSync('userId', response.data.data.id)
                           }
                         })
                        },
                      })   
                    }
                }
            });
        } else {
            // 已登录，可添加加载首页数据的逻辑
        }
  },
  globalData: {
    userInfo: null
  }
})
